export default {
  namespaced: true,
  state: {
		tabBarIndex: null,	// 当前tabBar下标 
		systemInfo: {
			navBarHeight: 0, // 导航栏高度
			menuRight: 0, // 胶囊距右方间距（方保持左、右间距一致）
			menuTop: 0, // 胶囊距底部间距（保持底部间距一致）
			menuHeight: 0, // 胶囊高度（自定义内容可与胶囊高度保证一致）
		},
		location: {	// 选择城市定位信息
			cityName: '',
			cityCode: '',
			longitude: '',
			latitude: '',
		},
		nowLocation: {	// 当前定位城市信息
			cityName: '',
			longitude: '',
			latitude: '',
			province: '',
		},
    showInfo: {}, // 小程序启动或切前台时的参数 App.vue -> onShow(showInfo)
		appConfig: {}, // 小程序id和密钥
		
		// 登录设备信息 --- 用于埋点自主上报接口
		deviceInfo: {	
			brand: '', // 设备品牌
			model: '', // 设备型号
			system: '', // 操作系统及版本
			platform: '小程序', // 客户端平台
			pageName: '', // 页面名称
			eventCode: '', // 事件代码
			userId: null, // 用户ID
			// eventDuration: null, // 持续时间(单位:秒)
			// businessId: null, // 业务ID
		},	
  },
  mutations: {
    setTabBarIndex: (state, data) => {
      state.tabBarIndex = data
    },
		setSystemInfo: (state, data) => {
			state.systemInfo.navBarHeight = data.navBarHeight
			state.systemInfo.menuRight = data.menuRight
			state.systemInfo.menuTop = data.menuTop
			state.systemInfo.menuHeight = data.menuHeight
		},
		setLocation: (state, data) => {
			state.location = data
		},
		setNowLocation: (state, data) => {
			state.nowLocation = data
		},
    setShowInfo: (state, data) => {
      state.showInfo = data
    },
		setAppConfig: (state, data) => {
			state.appConfig = data
		},
		setDeviceInfo: (state, data) => {
			state.deviceInfo = Object.assign(state.deviceInfo, data)
		}
  },
  actions: {
  },
	getters: {
		getTabBarIndex(state){
			return state.tabBarIndex
		},
		getSystemInfo(state){
			return state.systemInfo
		},
		getLocation(state){
			return state.location
		},
		getNowLocation(state){
			return state.nowLocation
		},
		getAppConfig(state){
			return state.appConfig
		},
		getDeviceInfo(state){
			return state.deviceInfo
		}
	}
}